package main;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import java.awt.event.KeyEvent;
import java.util.Arrays;

/**
 *
 * @author Kyle
 */
public class KeyDecoder {
    private Interpreter GC;
    private KeyDefinitions keyDefs;
    public KeyDecoder(Interpreter _GC, KeyDefinitions _keyDefs){
        GC = _GC;
        keyDefs = _keyDefs;
    }
    public KeyDefinitions getKeyDefs(){
    	return keyDefs;
    }
    void decode(KeyEvent e) {
    	int key[] = new int[2];
        key[0] = e.getKeyCode();
        key[1] = e.getModifiers();
        //SW
        if(Arrays.equals(key, keyDefs.getSouthWest())){
            GC.interpret("SW");
        }
        //S
        else if(Arrays.equals(key, keyDefs.getSouth())){
            GC.interpret("S");
        }
        //SE
        else if(Arrays.equals(key, keyDefs.getSouthEast())){
            GC.interpret("SE");
        }       
        //Focus
        else if(Arrays.equals(key, keyDefs.getFocus())){
            GC.interpret("Focus");
        }
        //NW
        else if(Arrays.equals(key, keyDefs.getNorthWest())){
            GC.interpret("NW");
        }
        //N
        else if(Arrays.equals(key, keyDefs.getNorth())){
            GC.interpret("N");
        }
        //NE
        else if(Arrays.equals(key, keyDefs.getNorthEast())){
            GC.interpret("NE");
        }
        //Issue
        else if(Arrays.equals(key, keyDefs.getIssue())){
            GC.interpret("Issue");
        }
        //modeNext
        else if(Arrays.equals(key, keyDefs.getModeNext())){
            GC.interpret("modeNext");
        }
        //modePrev
        else if(Arrays.equals(key, keyDefs.getModePrev())){
            GC.interpret("modePrev");
        }
        //typeNext
        else if(Arrays.equals(key, keyDefs.getTypeNext())){
            GC.interpret("typeNext");
        }
        //typePrev
        else if(Arrays.equals(key, keyDefs.getTypePrev())){
            GC.interpret("typePrev");
        }
        //instanceNext
        else if(Arrays.equals(key, keyDefs.getInstanceNext())){
            GC.interpret("instanceNext");
        }
        //instancePrev
        else if(Arrays.equals(key, keyDefs.getInstancePrev())){
            GC.interpret("instancePrev");
        }
        //commandNext
        else if(Arrays.equals(key, keyDefs.getCommandNext())){
            GC.interpret("commandNext");
        }
        //commandPrev
        else if(Arrays.equals(key, keyDefs.getCommandPrev())){
            GC.interpret("commandPrev");
        }
        //#1
        else if(Arrays.equals(key, keyDefs.getSelect1())){
            GC.interpret("#1");
        }
        //#2
        else if(Arrays.equals(key, keyDefs.getSelect2())){
            GC.interpret("#2");
        }
        //#3
        else if(Arrays.equals(key, keyDefs.getSelect3())){
            GC.interpret("#3");
        }
        //#4
        else if(Arrays.equals(key, keyDefs.getSelect4())){
            GC.interpret("#4");
        }
        //#5
        else if(Arrays.equals(key, keyDefs.getSelect5())){
            GC.interpret("#5");
        }
        //#6
        else if(Arrays.equals(key, keyDefs.getSelect6())){
            GC.interpret("#6");
        }
        //#7
        else if(Arrays.equals(key, keyDefs.getSelect7())){
            GC.interpret("#7");
        }
        //#8
        else if(Arrays.equals(key, keyDefs.getSelect8())){
            GC.interpret("#8");
        }
        //#9
        else if(Arrays.equals(key, keyDefs.getSelect9())){
            GC.interpret("#9");
        }
        //#0
        else if(Arrays.equals(key, keyDefs.getSelect0())){
            GC.interpret("#0");
        }
        else if(Arrays.equals(key, keyDefs.getPause())){
        	GC.interpret("Pause");
        }
        else if(Arrays.equals(key, keyDefs.getEditControls())){
        	GC.interpret("editControls");
        }
        else if(Arrays.equals(key, keyDefs.getTab())){
        	GC.interpret("Tab");
        }
        else if(Arrays.equals(key, keyDefs.getCreateRally())){
        	GC.interpret("createRally");
        }
        else if(Arrays.equals(key, keyDefs.getCancel())){
        	GC.interpret("Cancel");
        }
        else if(Arrays.equals(key, keyDefs.getSwitchView())){
        	GC.interpret("switchView");
        }
        else if(Arrays.equals(key, keyDefs.getSwitchToTree())){
        	GC.interpret("switchToTree");
        }
    }

}

